# Contributor: Kaspar Schleiser <kaspar@schleiser.de>
# Maintainer: Kaspar Schleiser <kaspar@schleiser.de>
pkgname=laze
pkgver=0.1.18
pkgrel=0
pkgdesc="laze is a build system based on Ninja, aiming to be the next goto-alternative to make"
url="https://laze-build.org"
arch="all"
license="Apache-2.0"
depends="ninja"
makedepends="cargo cargo-auditable"
checkdepends="xz"
subpackages="$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/kaspar030/laze/archive/$pkgver/laze-$pkgver.tar.gz"

prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 "target/release/laze" "$pkgdir/usr/bin/laze"

	# create man pages
	mkdir -p tmp/man tmp/completions
	target/release/laze manpage tmp/man

	install -Dm644 "tmp/man/laze.1" "$pkgdir/usr/share/man/man1/laze.1"
	install -Dm644 "tmp/man/laze-build.1" "$pkgdir/usr/share/man/man1/laze-build.1"
	install -Dm644 "tmp/man/laze-clean.1" "$pkgdir/usr/share/man/man1/laze-clean.1"

	# create completions
	for shell in bash zsh fish; do
		target/release/laze -Ctmp/completions completion --generate $shell \
			> tmp/completions/$shell
	done

	install -Dm644 "tmp/completions/bash" \
		"$pkgdir/usr/share/bash-completion/completions/laze"
	install -Dm644 "tmp/completions/fish" \
		"$pkgdir/usr/share/fish/vendor_completions.d/laze.fish"
	install -Dm644 "tmp/completions/zsh" \
		"$pkgdir/usr/share/zsh/site-functions/_laze"
}

sha512sums="
43b34322648b2ed6919b0e8939c44031dc3e4402026a61cda5ba03fb1543d7b51f6096e3a0bb141806536ab83067452b334240485593ab7b5606729a151fa3e0  laze-0.1.18.tar.gz
"
